package com.schematic.flixel.examples
	
{
import org.flixel.*;
import org.flixel.FlxSprite;

public class Mario extends FlxSprite	
{
		
	//--------------------------------------------------------------------------
    //
    //  Class Constants
    //
    //--------------------------------------------------------------------------
    
    //----------------------------------
    //  DEFAULT_SPEED
    //----------------------------------
    /**
     * The walk default speed
     */
    public static const DEFAULT_SPEED:Number = 32;
	
	//----------------------------------
	//  isArmed
	//----------------------------------
	/**
	 * walks armed / unarmed
	 */	
	private var isarmed:Boolean;
	
	public function get isArmed():Boolean
	{
		return isarmed;
	}
	
	public function set isArmed(value:Boolean):void
	{
		isarmed = value;
	} 
	
    
    //--------------------------------------------------------------------------
    //
    // Constructor
    //
    //--------------------------------------------------------------------------

    /**
     * Creates a new instance of this class.
     */
    public function Mario(x:Number = 0, y:Number = 0)
    {
        super(x, y);
		isArmed = false;
        speed = DEFAULT_SPEED;
        loadGraphic(Skins.MARIO, true, false, 32, 48, true);
        var frameRate:int = 8;
		
        addAnimation(
            "walkRight",
            [1, 2, 3],
            frameRate,
            true
        );
        addAnimation(
            "walkLeft",
            [4, 5, 6],
            frameRate,
            true
        );
        addAnimation(
            "stand",
            [0, 0, 0, 0, 0, 7, 7, 7, 7, 0],
            frameRate,
            true
        );

		addAnimation(
			"walkUp",
			[11, 12, 13],
			frameRate,
			true
		);	
		addAnimation(
			"walkDown",
			[8, 9, 10],
			frameRate,
			true
		);	
		addAnimation(
			"weaponWalkLeft",
			[16, 17, 18],
			frameRate,
			true
		);	
		addAnimation(
			"weaponWalkRight",
			[19, 20, 21],
			frameRate,
			true
		);	
		
		addAnimation(
			"weaponHitLeft",
			[15, 28, 27, 26, 25, 24, 34, 34, 24, 25, 26, 27, 28, 15],
			3*frameRate,
			true
		);	
		addAnimation(
			"weaponHitRight",
			[22, 29, 30, 31, 32, 33, 35, 35, 33, 32, 31, 30, 29, 22],
			3*frameRate,
			true
		);	
		
		addAnimation(
			"marioDieLeft",
			[23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23],
			frameRate,
			true
		);	
		

    }
	
	

    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  currentVelocity
    //----------------------------------
    /**
     *  @private
     */
    private var currentVelocityX:Number;
	/**
	 *  @private
	 */
	private var currentVelocityY:Number;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    // speed
    //----------------------------------
    /**
     * The current walk speed.
     */
    public var speed:Number;

    //--------------------------------------------------------------------------
    //
    //  Overridden Methods - FlxSprite
    //
    //--------------------------------------------------------------------------
    
    override public function update():void
    {
        velocity.x = currentVelocityX;
		velocity.y = currentVelocityY;
			
        super.update();
		
    }
    
    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------
	
    //----------------------------------
    //  walkRight
    //----------------------------------
    /**
     * makes Mario walk right
     */
    public function walkRight():void
    {
        	play("walkRight");
        	currentVelocityX = speed;
    } 

    //----------------------------------
    //  walkLeft
    //----------------------------------
    /**
     * makes Mario walk left
     */
    public function walkLeft():void
    {
			play("walkLeft");
			currentVelocityX = -speed;
    } 
	
	//----------------------------------
	//  walkUp
	//----------------------------------
	/**
	 * makes Mario walk Up
	 */
	public function walkUp():void
	{
		play("walkUp");
		currentVelocityY = -speed;
	} 
	/**
	 * makes Mario walk Down
	 */
	public function walkDown():void
	{
		play("walkDown");
		currentVelocityY = speed;
	} 

    //----------------------------------
    //  stand
    //----------------------------------
    /**
     * Makes Mario stop
     */
    public function stand():void
    {
        play("stand");  
        currentVelocityX = 0;
		currentVelocityY = 0;
    }
	
	//----------------------------------
	//  walkRightArmed
	//----------------------------------
	/**
	 * makes Mario walk right
	 */
	public function weaponWalkRight():void
	{
		play("weaponWalkRight");
		currentVelocityX = speed;
	} 
	
	//----------------------------------
	//  walkLeftArmed
	//----------------------------------
	/**
	 * makes Mario walk left
	 */
	public function weaponWalkLeft():void
	{
		play("weaponWalkLeft");
		currentVelocityX = -speed;
	} 	
	
	//----------------------------------
	//  HitLeftArmed
	//----------------------------------
	/**
	 * makes Mario Hit when he walks to the left
	 */
	public function weaponHitLeft():void
	{
		play("weaponHitLeft");
		currentVelocityX = -speed;
	} 	

	
	//----------------------------------
	//  HitLeftArmed
	//----------------------------------
	/**
	 * makes Mario Hit when he walks to the left
	 */
	public function weaponHitRight():void
	{
		play("weaponHitRight");
		currentVelocityX = speed;
	} 	
	
	//----------------------------------
	//  MarioDieFromLeft
	//----------------------------------
	/**
	 * makes Mario Hit when he walks to the left
	 */
	public function marioDieLeft():void
	{
		play("marioDieLeft");
		currentVelocityX = 0;
		currentVelocityY = 0;
	} 	
	
	
}
}